home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / linux / tools / gtar10.lha / getdate.c < prev    next >
C/C++ Source or Header  |  1992-09-09  |  45KB  |  1,775 lines

  1.  
  2. /*  A Bison parser, made from getdate.y  */
  3.  
  4. #define YYBISON 1  /* Identify Bison output.  */
  5.  
  6. #define    tAGO    258
  7. #define    tDAY    259
  8. #define    tDAYZONE    260
  9. #define    tID    261
  10. #define    tMERIDIAN    262
  11. #define    tMINUTE_UNIT    263
  12. #define    tMONTH    264
  13. #define    tMONTH_UNIT    265
  14. #define    tSEC_UNIT    266
  15. #define    tSNUMBER    267
  16. #define    tUNUMBER    268
  17. #define    tZONE    269
  18.  
  19. #line 1 "getdate.y"
  20.  
  21. /* $Revision: 2.1 $
  22. **
  23. **  Originally written by Steven M. Bellovin <smb@research.att.com> while
  24. **  at the University of North Carolina at Chapel Hill.  Later tweaked by
  25. **  a couple of people on Usenet.  Completely overhauled by Rich $alz
  26. **  <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
  27. **  send any email to Rich.
  28. **
  29. **  This grammar has eight shift/reduce conflicts.
  30. **
  31. **  This code is in the public domain and has no copyright.
  32. */
  33. /* SUPPRESS 287 on yaccpar_sccsid *//* Unusd static variable */
  34. /* SUPPRESS 288 on yyerrlab *//* Label unused */
  35.  
  36. #ifdef __GNUC__
  37. #define alloca __builtin_alloca
  38. #else
  39. #ifdef sparc
  40. #include <alloca.h>
  41. #else
  42. #ifdef _AIX /* for Bison */
  43. #pragma alloca
  44. #else
  45. char *alloca ();
  46. #endif
  47. #endif
  48. #endif
  49.  
  50. #include <stdio.h>
  51. #include <ctype.h>
  52.  
  53. #if    defined(vms)
  54. #include <types.h>
  55. #include <time.h>
  56. #else
  57. #include <sys/types.h>
  58. #if    defined(USG)
  59. /*
  60. **  Uncomment the next line if you need to do a tzset() call to set the
  61. **  timezone, and don't have ftime().  Some SystemV releases, I think.
  62. */
  63. /*#define NEED_TZSET */
  64. struct timeb {
  65.     time_t        time;        /* Seconds since the epoch    */
  66.     unsigned short    millitm;    /* Field not used        */
  67.     short        timezone;
  68.     short        dstflag;    /* Field not used        */
  69. };
  70. #else
  71. #include <sys/timeb.h>
  72. #endif    /* defined(USG) */
  73. #if    defined(BSD4_2) || defined(BSD4_1C)
  74. #include <sys/time.h>
  75. #else
  76. #include <time.h>
  77. #endif    /* defined(BSD4_2) */
  78. #endif    /* defined(vms) */
  79.  
  80. #if defined (STDC_HEADERS) || defined (USG)
  81. #include <string.h>
  82. #endif
  83.  
  84. extern struct tm    *localtime();
  85.  
  86. #define yyparse getdate_yyparse
  87. #define yylex getdate_yylex
  88. #define yyerror getdate_yyerror
  89.  
  90. #if    !defined(lint) && !defined(SABER)
  91. static char RCS[] =
  92.     "$Header: str2date.y,v 2.1 90/09/06 08:15:06 cronan Exp $";
  93. #endif    /* !defined(lint) && !defined(SABER) */
  94.  
  95.  
  96. #define EPOCH        1970
  97. #define HOUR(x)        (x * 60)
  98. #define SECSPERDAY    (24L * 60L * 60L)
  99.  
  100.  
  101. /*
  102. **  An entry in the lexical lookup table.
  103. */
  104. typedef struct _TABLE {
  105.     char    *name;
  106.     int        type;
  107.     time_t    value;
  108. } TABLE;
  109.  
  110.  
  111. /*
  112. **  Daylight-savings mode:  on, off, or not yet known.
  113. */
  114. typedef enum _DSTMODE {
  115.     DSTon, DSToff, DSTmaybe
  116. } DSTMODE;
  117.  
  118. /*
  119. **  Meridian:  am, pm, or 24-hour style.
  120. */
  121. typedef enum _MERIDIAN {
  122.     MERam, MERpm, MER24
  123. } MERIDIAN;
  124.  
  125.  
  126. /*
  127. **  Global variables.  We could get rid of most of these by using a good
  128. **  union as the yacc stack.  (This routine was originally written before
  129. **  yacc had the %union construct.)  Maybe someday; right now we only use
  130. **  the %union very rarely.
  131. */
  132. static char    *yyInput;
  133. static DSTMODE    yyDSTmode;
  134. static time_t    yyDayOrdinal;
  135. static time_t    yyDayNumber;
  136. static int    yyHaveDate;
  137. static int    yyHaveDay;
  138. static int    yyHaveRel;
  139. static int    yyHaveTime;
  140. static int    yyHaveZone;
  141. static time_t    yyTimezone;
  142. static time_t    yyDay;
  143. static time_t    yyHour;
  144. static time_t    yyMinutes;
  145. static time_t    yyMonth;
  146. static time_t    yySeconds;
  147. static time_t    yyYear;
  148. static MERIDIAN    yyMeridian;
  149. static time_t    yyRelMonth;
  150. static time_t    yyRelSeconds;
  151.  
  152.  
  153. #line 135 "getdate.y"
  154. typedef union {
  155.     time_t        Number;
  156.     enum _MERIDIAN    Meridian;
  157. } YYSTYPE;
  158.  
  159. #ifndef YYLTYPE
  160. typedef
  161.   struct yyltype
  162.     {
  163.       int timestamp;
  164.       int first_line;
  165.       int first_column;
  166.       int last_line;
  167.       int last_column;
  168.       char *text;
  169.    }
  170.   yyltype;
  171.  
  172. #define YYLTYPE yyltype
  173. #endif
  174.  
  175. #include <stdio.h>
  176.  
  177. #ifndef __STDC__
  178. #define const
  179. #endif
  180.  
  181.  
  182.  
  183. #define    YYFINAL        48
  184. #define    YYFLAG        -32768
  185. #define    YYNTBASE    18
  186.  
  187. #define YYTRANSLATE(x) ((unsigned)(x) <= 269 ? yytranslate[x] : 28)
  188.  
  189. static const char yytranslate[] = {     0,
  190.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  191.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  192.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  193.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  194.      2,     2,     2,    16,     2,     2,    17,     2,     2,     2,
  195.      2,     2,     2,     2,     2,     2,     2,    15,     2,     2,
  196.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  197.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  198.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  199.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  200.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  201.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  202.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  203.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  204.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  205.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  206.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  207.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  208.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  209.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  210.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  211.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  212.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  213.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  214.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  215.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  216.      6,     7,     8,     9,    10,    11,    12,    13,    14
  217. };
  218.  
  219. #if YYDEBUG != 0
  220. static const short yyprhs[] = {     0,
  221.      0,     1,     4,     6,     8,    10,    12,    14,    16,    19,
  222.     24,    29,    36,    43,    45,    47,    49,    52,    55,    59,
  223.     65,    68,    73,    76,    80,    83,    85,    88,    91,    93,
  224.     96,    99,   101,   104,   107,   109,   111,   112
  225. };
  226.  
  227. #endif
  228.  
  229. static const short yyrhs[] = {    -1,
  230.     18,    19,     0,    20,     0,    21,     0,    23,     0,    22,
  231.      0,    24,     0,    26,     0,    13,     7,     0,    13,    15,
  232.     13,    27,     0,    13,    15,    13,    12,     0,    13,    15,
  233.     13,    15,    13,    27,     0,    13,    15,    13,    15,    13,
  234.     12,     0,    14,     0,     5,     0,     4,     0,     4,    16,
  235.      0,    13,     4,     0,    13,    17,    13,     0,    13,    17,
  236.     13,    17,    13,     0,     9,    13,     0,     9,    13,    16,
  237.     13,     0,    13,     9,     0,    13,     9,    13,     0,    25,
  238.      3,     0,    25,     0,    13,     8,     0,    12,     8,     0,
  239.      8,     0,    12,    11,     0,    13,    11,     0,    11,     0,
  240.     12,    10,     0,    13,    10,     0,    10,     0,    13,     0,
  241.      0,     7,     0
  242. };
  243.  
  244. #if YYDEBUG != 0
  245. static const short yyrline[] = { 0,
  246.    149,   150,   153,   156,   159,   162,   165,   168,   171,   177,
  247.    183,   190,   196,   206,   210,   216,   220,   224,   230,   234,
  248.    239,   243,   248,   252,   259,   263,   266,   269,   272,   275,
  249.    278,   281,   284,   287,   290,   295,   323,   326
  250. };
  251.  
  252. static const char * const yytname[] = {   "$","error","$illegal.","tAGO","tDAY",
  253. "tDAYZONE","tID","tMERIDIAN","tMINUTE_UNIT","tMONTH","tMONTH_UNIT","tSEC_UNIT",
  254. "tSNUMBER","tUNUMBER","tZONE","':'","','","'/'","spec","item","time","zone",
  255. "day","date","rel","relunit","number","o_merid",""
  256. };
  257. #endif
  258.  
  259. static const short yyr1[] = {     0,
  260.     18,    18,    19,    19,    19,    19,    19,    19,    20,    20,
  261.     20,    20,    20,    21,    21,    22,    22,    22,    23,    23,
  262.     23,    23,    23,    23,    24,    24,    25,    25,    25,    25,
  263.     25,    25,    25,    25,    25,    26,    27,    27
  264. };
  265.  
  266. static const short yyr2[] = {     0,
  267.      0,     2,     1,     1,     1,     1,     1,     1,     2,     4,
  268.      4,     6,     6,     1,     1,     1,     2,     2,     3,     5,
  269.      2,     4,     2,     3,     2,     1,     2,     2,     1,     2,
  270.      2,